<template>
  <el-table-column v-if="$attrs.ctype == 'selection'" v-bind="$attrs" :width="colWidth" class-name="table-td"/>
  <el-table-column v-else-if="$attrs.ctype == 'index'" v-bind="$attrs" show-overflow-tooltip align="center" :width="colWidth" class-name="table-td"/>
  <el-table-column v-else-if="$attrs.hasOwnProperty('searchable') && $scopedSlots.default" v-bind="$attrs" show-overflow-tooltip :width="colWidth" class-name="table-td">
    <template slot="header" slot-scope="{column}">
      <ad-table-header-filter v-bind="column" :queryName="$attrs.searchable" @search="$emit('search')"/>
    </template>
    <template slot-scope="{row}">
      <slot :row="row"></slot>
    </template>
  </el-table-column>
  <el-table-column v-else-if="$attrs.hasOwnProperty('searchable') && $attrs.hasOwnProperty('href')" v-bind="$attrs" show-overflow-tooltip :width="colWidth" class-name="table-td">
    <template slot="header" slot-scope="{column}">
      <ad-table-header-filter v-bind="column" :queryName="$attrs.searchable" @search="$emit('search')"/>
    </template>
    <template slot-scope="scope">
      <el-link @click="$router.push({path: $attrs.href, query: {id: scope.row.id}})">{{scope.row[scope.column.property]}}</el-link>
    </template>
  </el-table-column>
  <el-table-column v-else-if="$attrs.hasOwnProperty('searchable')" v-bind="$attrs" show-overflow-tooltip :width="colWidth" class-name="table-td">
    <template slot="header" slot-scope="{column}">
      <ad-table-header-filter v-bind="column" :queryName="$attrs.searchable" @search="$emit('search')"/>
    </template>
  </el-table-column>
  <el-table-column v-else-if="$attrs.hasOwnProperty('dictName')" v-bind="$attrs" show-overflow-tooltip :width="colWidth" class-name="table-td">
    <template slot-scope="scope">{{scope.row[scope.column.property] !== "" ? parseStatus(dict, $attrs.dictName, scope.row[scope.column.property]) : '-'}}</template>
  </el-table-column>
  <el-table-column v-else-if="$scopedSlots.default" v-bind="$attrs" show-overflow-tooltip :width="colWidth" class-name="table-td">
    <template slot-scope="{row}">
      <slot :row="row"></slot>
    </template>
  </el-table-column>
  <el-table-column v-else v-bind="$attrs" show-overflow-tooltip :width="colWidth" class-name="table-td">
    <template slot-scope="scope">{{scope.column.property ? (isNull(scope.row[scope.column.property]) || scope.row[scope.column.property] === ''  ?  '-' : scope.row[scope.column.property] ) : ''}}</template>
  </el-table-column>
</template>

<script>
import AdTableHeaderFilter from '../AdTableHeaderSearch'
import config from './mixins/config'
import mixins from './mixins/index'

export default {
  components: { AdTableHeaderFilter },
  mixins: [ config, mixins ]
}
</script>